package com.plian.system.dao.pm.property;

import com.plian.Tools.pagedata.PageData;
import com.plian.system.dao.DaoSupport;
import com.plian.system.model.page.Page;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class PropertyBasicsDao {
    @Resource(name = "daoSupport")
    private DaoSupport dao;

    /**
     * 新增
     * @param pd
     * @throws Exception
     */
    public void save(PageData pd) throws Exception {
        dao.save("PropertyBasicsMapper.save",pd);
    }

    /**
     * 修改
     * @param pd
     * @throws Exception
     */
    public void edit(PageData pd) throws Exception {
        dao.update("PropertyBasicsMapper.edit",pd);
    }

    /**
     * * 根据Id获取最新的一条数据
     * @param id
     * @return
     * @throws Exception
     */
    public PageData findbyid(String id) throws Exception {
        return (PageData) dao.findForObject("PropertyBasicsMapper.findbyid",id);
    }

    /**
     * 根据orgId获取最新的一条数据
     * @return
     * @throws Exception
     */
    public PageData findByorgId(String orgId) throws Exception {
        return (PageData) dao.findForObject("PropertyBasicsMapper.findByorgId",orgId);
    }

    /**
     * 根据orgId获取最新的一条数据
     * @return
     * @throws Exception
     */
    public PageData findByOrgIdAndCom(PageData pageData) throws Exception {
        return (PageData) dao.findForObject("PropertyBasicsMapper.findByOrgIdAndCom", pageData);
    }

    /**
     * 根据orgId获取最新的一条数据
     * @return
     * @throws Exception
     */
    public PageData findSimpleByOrgId(PageData pageData) throws Exception {
        return (PageData) dao.findForObject("PropertyBasicsMapper.findSimpleByOrgId", pageData);
    }

    public List<PageData> findByorgName(String orgName) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.findByorgName",orgName);
    }

    public void delByIds(List<String> ids) throws Exception {
        dao.delete("PropertyBasicsMapper.delByIds",ids);
    }

    public void updatePropertyCodeByIds(List<String> ids) throws Exception {
        dao.update("PropertyBasicsMapper.updatePropertyCodeByIds",ids);
    }

    /**
     * 修改状态
     * @param pd
     */
    public void  refer(PageData pd) throws Exception {
        dao.update("PropertyBasicsMapper.refer",pd);
    }
    /**
     * 修改状态
     * @param pd
     */
    public List<PageData> findByIds(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.findByIds",pd);
    }

    /**
     * 获取所有一级企业
     * @return
     * @throws Exception
     */
    public List<PageData> allFirstCompany() throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.allFirstCompany",null);
    }

    /**
     * 根据多单位查询列表
     * @param page
     * @return
     * @throws Exception
     */
    public List<PageData> reportListPage(Page page) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.reportListPage",page);
    }

    /**
     * 根据多单位查询列表 主要出资人
     * @param page
     * @return
     * @throws Exception
     */
    public List<PageData> reportParentListPage(Page page) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.reportParentListPage",page);
    }
    public List<PageData> list(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.list",pd);
    }

    public List<PageData> listInfo(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.listInfo",pd);
    }

    public List<PageData> simpleList(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.simpleList",pd);
    }
    public List<PageData> listAll(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.listAll",pd);
    }
    public List<PageData> reportList(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.reportList",pd);
    }
    public List<PageData> reportParentList(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.reportParentList",pd);
    }
    public List<PageData> reportListPage(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.reportListPage",pd);
    }
    public List<PageData> orgListPage(Page page) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.orgListPage",page);
    }
    public void editByOrgId(PageData pd) throws Exception {
        dao.update("PropertyBasicsMapper.editByOrgId",pd);
    }
    public void editByOrgIdAll(List<PageData> list) throws Exception {
        dao.update("PropertyBasicsMapper.editByOrgIdAll",list);
    }
    public List<PageData> findChild(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.findChild",pd);
    }
    public void editAll(List<PageData> list) throws Exception {
         dao.batchSave("PropertyBasicsMapper.editAll",list);
    }

    public void updateOrgCode(List<PageData> list) throws Exception {
        dao.batchSave("PropertyBasicsMapper.updateOrgCode",list);
    }

    /**
     * 根据时间段返回产权信息
     * @param
     * @return
     * @throws Exception
     */
    public List<PageData> findListByDateRange(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.findListByDateRange", pd);
    }
    /**
     * 第一次获取全部产权信息
     * @param
     * @return
     * @throws Exception
     */
    public List<PageData> findListRange(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyBasicsMapper.findListRange", pd);
    }
}
